﻿using System;
using ExtraClub.Domain;
using ExtraClub.Domain.Entities;
using SubSonic;
using System.Collections.Generic;
using ExtraClub.Domain.Forms;

namespace ExtraClub.Web.Forms.club_filter {
    public partial class module : BaseFilter {
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
        }

        protected override string SetFields() {
            return BuildFilterForm();
        }

        private string BuildFilterForm() {
            string key = "club_grid_filter";
            Dictionary<string, object> data = (Dictionary<string, object>)Session[key];

            FieldCollection fs = new FieldCollection();
            fs.Control = this;
            fs.LabelKeySuffex = "-label";

            AddHiddenFieldes(ref fs, "");

            /* User Name */
            new Field(FieldType.String, VwClubProfile.Columns.UserName.ToLower(), f =>
            {
                f.Size = 30;
                f.Value = data != null ? data[f.CodeName].ToString() : "";
            }, fs);

            /* Email */
            new Field(FieldType.String, VwClubProfile.Columns.Email.ToLower(), f =>
            {
                f.Size = 30;
                f.Value = data != null ? data[f.CodeName].ToString() : "";
            }, fs);

            /* Pass */
            new Field(FieldType.String, VwClubProfile.Columns.Password.ToLower(), f =>
            {
                f.Size = 20;
                f.Value = data != null ? data[f.CodeName].ToString() : "";
            }, fs);

            /* First Name */
            new Field(FieldType.String, VwClubProfile.Columns.FirstName.ToLower(), f =>
            {
                f.Size = 30;
                f.Value = data != null ? data[f.CodeName].ToString() : "";
            }, fs);

            /* Compony Name */
            new Field(FieldType.String, VwClubProfile.Columns.Name.ToLower(), f =>
            {
                f.Size = 30;
                f.Value = data != null ? data[f.CodeName].ToString() : "";
            }, fs);

            return fs.JSON();
        }
    }
}
